package com.nidu.demo.notify.convertor;

import com.nidu.demo.base.BaseConvertor;
import com.nidu.demo.convertor.MapStructConfig;
import com.nidu.demo.notify.dto.NotifyTemplateCO;
import com.nidu.demo.notify.mapper.dataobject.NotifyTemplateDO;
import com.nidu.demo.notify.model.NotifyTemplate;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(config = MapStructConfig.class)
public interface NotifyTemplateConvertor extends BaseConvertor<NotifyTemplateDO, NotifyTemplate, NotifyTemplateCO> {
    
    @Override
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "updateBy", ignore = true)
    @Mapping(source = "templateName", target = "name")
    @Mapping(source = "templateCode", target = "code")
    @Mapping(source = "templateNickname", target = "nickname")
    @Mapping(source = "templateContent", target = "content")
    @Mapping(source = "templateType", target = "type")
    @Mapping(source = "templateParams", target = "params")
    NotifyTemplateDO toDataObject(NotifyTemplate notifyTemplate);

    @Override
    @Mapping(source = "code", target = "templateCode")
    @Mapping(source = "nickname", target = "templateNickname")
    @Mapping(source = "content", target = "templateContent")
    @Mapping(source = "type", target = "templateType")
    @Mapping(source = "params", target = "templateParams")
    NotifyTemplate toDomainObject(NotifyTemplateDO notifyTemplateDO);

}
